function checkForm(regform){
	
	var regName = document.regform['model.regname'].value.replace(/[ ]/g,"").replace(/[　]/g,""); //去掉全角、半角空格
	var regPwd = document.regform['model.regpwd'].value.replace(/[ ]/g,"").replace(/[　]/g,"");
	var confirmPwd = document.regform.confirmPwd.value.replace(/[ ]/g,"").replace(/[　]/g,"");
	var regEmail = document.regform['model.regemail'].value.replace(/[ ]/g,"").replace(/[　]/g,"");
	var verifyCodeInput = document.regform.verifyCodeInput.value.replace(/[ ]/g,"").replace(/[　]/g,"");
	var randNum = document.regform.randNum.value;
	//alert(verifyCodeInput);
	var reg = /([a-zA-Z0-9]|[_]){5,20}$/;   //	5-20个字符,包括字母、数字、下划线
	var reg2 = /([a-zA-Z0-9]|[_]){6,18}$/;   //	6-18个字符,包括字母、数字、下划线
	//var verifyEmail = /^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$/;
	var verifyEmail = /[A-Za-z0-9_.]+[A-Za-z0-9]+\@([A-Za-z0-9_]+\.)+[a-zA-Z]{2,}$/; 
	//var reg = /[^\u4e00-\u9fa5]/;   //中文的正则表达式
	if(regName == ""){
		window.alert("请输入用户名");
		regform['model.regname'].focus(); //将光标定位再输入用户名的文本框内
		return false;  //返回i一个"false"错误值使表单中的值不能被发送到服务器
	}else if(!reg.exec(regName)){
		alert("用户名不符合要求");
		regform['model.regname'].focus(); 
		return false; 
	}
	if(regPwd ==""){
		window.alert("没有输入密码!");
		regform['model.regpwd'].focus();
		return false;
	}else if(!reg2.exec(regPwd)){
		alert("密码不符合要求");
		regform['model.regpwd'].focus();
		return false;
	}
	if(confirmPwd == ""){
		window.alert ("没有输入确认密码!");
		regform.confirmPwd.focus();
		return false;
	}else if(regPwd != confirmPwd){
		window.alert ("确认密码与密码不同!");
		regform.confirmPwd.focus();
		return false;
	}
	if(regEmail == ""){
		alert("没有输入Email地址");
		regform['model.regemail'].focus();
		return false;
	}else if(!verifyEmail.exec(regEmail)){
		alert("Email格式不正确。");
		regform['model.regemail'].focus();
		return false;
	}
	if(verifyCodeInput == ""){
		alert("没有输入校验码");
		regform.verifyCodeInput.focus();
		return false;
	}else if(isNaN(verifyCodeInput) || verifyCodeInput.length!=4){
		alert("校验码输入错误");
		regform.verifyCodeInput.focus();
		return false;
	}
	return true;
}



//检测用户名

function checkName(obj){
	if(obj.value == null || obj.value == ''){
		document.getElementById("nameMsg").innerHTML = "<font  color = red>用户名为空</font>";
		return false;
	}
	var patrn=/([a-zA-Z0-9]|[_]){5,20}$/;  
    if (!patrn.exec(obj.value)){
		document.getElementById("nameMsg").innerHTML = "<font color = red>用户名不合法!</font>";
    	 return false;  
    }
    document.getElementById("nameMsg").innerHTML = "";
    
    var username = obj.value;
	checkNameExits.CheckNameAndEmail(username,"USERNAME",callbackName);
}

function callbackName(data){
	if(!data){
		 document.getElementById("nameMsg").innerHTML = "<font color = red>用户名已经存在</font>";		 
	}
}
//检测邮箱
function checkEmail(obj){
	var email = obj.value;

	if(email == ""){
	  	document.getElementById("emailMsg").innerHTML = "<font color = red>邮箱为空!</font>";
  		return false; 
	}
	var patrn=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;     
  	if (!patrn.exec(email))     
  	{   
  		document.getElementById("emailMsg").innerHTML = "<font color = red>邮箱不合法!</font>";
  		return false;   
  	} 

	document.getElementById("emailMsg").innerHTML =  "";

	checkEmailExits.CheckNameAndEmail(email,"EMAIL",callbackEmail);
	
}
function callbackEmail(data){
	if(!data){
		document.getElementById("emailMsg").innerHTML =  "<font color = red>邮箱已经存在</font>";
	}
}
//检测验证码
function checkVcode(obj){

	var code = obj.value;
	
	if(code == null || code == ""){
		document.getElementById("codeMsg").innerHTML = "<font color = red>验证码为空!</font>";
	}

	document.getElementById("codeMsg").innerHTML = "";

	checkCodeIsRight.CheckCode(code,callbackVCode);
}
function callbackVCode(data){
	if(!data){	
		document.getElementById("codeMsg").innerHTML = "<font color = red>验证码错误!</font>";
	}
}
//检测密码
function checkPwd(obj){
	var userpwd = obj.value;
	if(obj.value == null || obj.value == ""){
		document.getElementById("pwdMsg").innerHTML = "<font color = red>密码为空!</font>";
    	return false ;
	}
	

 	var patrn=/^(\w){6,18}$/;  
    if (!patrn.exec(userpwd)) {
    	document.getElementById("pwdMsg").innerHTML = "<font color = red>密码不合法!</font>";
    	return false;
	}
	
	var patrnAll = /([a-z][A-Z][0-9])+/;
	if(patrnAll.exec(userpwd)){
		document.getElementById("pwdMsg").innerHTML = "<font color = red>密码只可以是数字或字母!</font>";
		return false;
	}

 	
 		else{
	document.getElementById("pwdMsg").innerHTML = "";
	return true;
	}
}
//检测重复密码
function checkRePwd(obj){
	var pwd = document.getElementById("regpwd").value;
	if(pwd != obj.value){
		document.getElementById("repwdMsg").innerHTML = "<font color = red>密码不一致!</font>";
		return false;
	}
	
	else{
	document.getElementById("repwdMsg").innerHTML = "";
	return true;
	}
}

